<template>
    <div style="width:400px">
    
        <el-form ref="ruleForm" :model="ruleForm"  label-width="100px"   class="demo-ruleForm">
     
  <el-form-item label="部门名称" prop="DeptName">
    <el-input v-model="ruleForm.DeptName"></el-input>
  </el-form-item>
  <el-form-item label="描述" prop="Remark">
    <el-input v-model="ruleForm.Remark"></el-input>
  </el-form-item>
  <el-form-item label="状态" prop="Type" v-show="Type">
    <el-switch v-model="ruleForm.Type" active-value="1" inactive-value="0"  ></el-switch>
    </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')" icon="el-icon-menu">新增</el-button>
    <el-button @click="resetForm('ruleForm')" icon="el-icon-refresh-left">重置</el-button>
  </el-form-item>
</el-form>
    </div>
</template>

<script>
export default {
    name:'Add',
    data(){
        return {
            ruleForm:{
             DeptName:'',
             Remark:'',
             Type:false,
             LastTime:''

            }
           
          
        }
    },
    props:['dialogAdd'],
    methods:{
        submitForm(formName) {
            //先验证表单数据
            this.$refs[formName].validate((valid) => {
                if (valid) {
                  console.log(this.ruleForm)
               this.axios({
                method:'post',
                url:'Dept',
                data:this.ruleForm
            }).then(res=>{
                if(res.code>0){
                  this.$emit('update:dialogAdd',false)
                  this.$emit("gx");
                    this.$message({ type:'success', message:res.msg})

                }else{
                    this.$message({ type:'danger', message:res.msg})
                }
            })
             
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        }

    }
    
}
</script>

<style scoped>
</style>